/*
 * @Author: your name
 * @Date: 2021-07-20 09:08:22
 * @LastEditTime: 2021-07-27 19:38:01
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \geek-client-mobile\src\store\modules\user.js
 */
// 用户模块共享数据管理
export default {
  namespaced: true,
  // 状态
  state () {
    return {
      // 命令，初始化从本地获取
      token: localStorage.getItem('geek-client-mobile-token'),
      refreshToken: localStorage.getItem('geek-client-mobile-refreshToken')
    }
  },
  // 修改
  mutations: {
    setToken (state, token) {
      // 1. 修改vuex的数据
      state.token = token
      // 2. 同步修改本地
      localStorage.setItem('geek-client-mobile-token', token)
    },
    setRefreshToken (state, refreshToken) {
      // 1. 修改vuex的数据
      state.refreshToken = refreshToken
      // 2. 同步修改本地
      localStorage.setItem('geek-client-mobile-refreshToken', refreshToken)
    }
  }
}
